/*
 * Copyright (c) 2011 Team A CS2340. All rights reserved.
 */

package edu.gatech.teama.doctorsoffice.net;

import java.io.Serializable;

import edu.gatech.teama.doctorsoffice.server.DataModel;


/**
 * Describes the message protocol for client/server communication.
 * Extend this class and implement <code>handle(Model)</code>
 * as appropriate for the particular message type.
 * @author Dylan
 * @version 1.0
 */
public abstract class Message implements Serializable {

	/**
	 * payload is an object stored as message type
	 */
	private final Object payload;
	
	/**
	 * initialize instance payload
	 * @param objPayload the object write in message
	 */
	public Message(Object objPayload) {
        payload = objPayload;
    }
	
	/**
	 * Payload is stored as an <code>Object</code>
	 * but it's type may vary per message type.
	 * @return message's payload as an <code>Object</code>
	 */
	public Object getPayload() {
        return payload;
    }
	
	/**
	 * send message for particular object
	 * @param model data to manipulate
	 * @return message created
	 */
	public abstract Message handle(final DataModel model);
	
	public String toString() { // $codepro.audit.disable methodJavadoc
		return this.getPayload().toString();
	}
}
